package com.sysu.homework.DAO.Impl;

import javax.annotation.Resource;

import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.stereotype.Component;

import com.sysu.homework.DAO.TeachAssistantDAO;
import com.sysu.homework.DAO.TeacherDAO;
import com.sysu.homework.model.TeachAssistant;
import com.sysu.homework.model.Teacher;

@Component("teachAssistantDAO")
public class TeachAssistantDAOImpl implements TeachAssistantDAO {
	private HibernateTemplate hibernateTemplate;

	@Override
	public TeachAssistant getTeachAssistantById(int id) {
		TeachAssistant ta =  (TeachAssistant)hibernateTemplate.get(TeachAssistant.class, id);
		return ta;
	}
	@Override
	public boolean isValid(int id, String password) {
		TeachAssistant ta = (TeachAssistant)hibernateTemplate.get(TeachAssistant.class, id);
		if (ta != null && ta.getPassword().equals(password))
			return true;
		return false;
	}

	@Resource
	public void setHibernateTemplate(HibernateTemplate hibernateTemplate) {
		this.hibernateTemplate = hibernateTemplate;
	}

	public HibernateTemplate getHibernateTemplate() {
		return hibernateTemplate;
	}

	

}
